const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs')

const now = dayjs()
const year = now.get('year')
const month = now.get('month')
const day = now.get('date')

const dir = path.resolve('./log')
const fileName = `${year}-${month}-${day}.log`
const dirFile = path.resolve(dir, fileName)

function writeLog(data) {
  fs.appendFile(dirFile, data, function (err) {
    // console.log(err)
  })
}

module.exports = writeLog
